package com.teamwork;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class CheckScore {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生ID以查分：");
        int studentId = scanner.nextInt();
    }
        public static void checkscore(int studentId) {
        try (Connection conn = DBUtil.getConnection()) 
        {
            String sql = "SELECT EName, TScore, SScore FROM sc WHERE SId = ?";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setInt(1, studentId);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                String examName = rs.getString("EName");
                int totalScore = rs.getInt("TScore");
                int studentScore = rs.getInt("SScore");
                System.out.println("试卷名称：" + examName + ", 总分：" + totalScore + ", 学生得分：" + studentScore);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        }
}

